const eventBuses = {};

export default function () {
  const eventBusEmit = (eventName, payload) => {
    if (!eventBuses[eventName]) {
      eventBuses[eventName] = useEventBus(eventName);
    }
    eventBuses[eventName].emit(payload);
  };
  const eventBusOn = (eventName, callback) => {
    if (!eventBuses[eventName]) {
      eventBuses[eventName] = useEventBus(eventName);
    }
    return eventBuses[eventName].on(callback);
  };
  return {
    eventBusOn,
    eventBusEmit,
  };
}
